import torch
import torch.nn as nn

# 定义输入和双线性层的维度
D1, D2, M = 3, 4, 2
N = 2

# 创建双线性层
bilinear = nn.Bilinear(D1, D2, M)

# 创建两个输入张量
X1 = torch.tensor([
    [1.,1.,1.],
    [1.,1.,1.]
])
print(X1)
X2 = torch.tensor([
    [2.,2.,2.,2],
    [2.,2.,2.,2.]
])
print(X2)

# 计算双线性层的输出
Y = bilinear(X1, X2)
print(Y)
print(Y.shape)  # 打印输出张量的维度
